package com.itsc.service;

import java.util.List;

import com.itsc.dao.DictionaryDao;
import com.itsc.entities.Dictionary;
import com.itsc.service.inter.IDictionaryService;
import com.itsc.util.page.Page;

public class DictionaryService implements IDictionaryService{

	private DictionaryDao dictionaryDao;
	
	public void setDictionaryDao(DictionaryDao dictionaryDao) {
		this.dictionaryDao = dictionaryDao;
	}

	@Override
	public void save(Dictionary dictionary) {
		// TODO Auto-generated method stub
		dictionaryDao.save(dictionary);
	}

	@Override
	public void delete(Dictionary dictionary) {
		// TODO Auto-generated method stub
		dictionaryDao.delete(dictionary);
	}

	@Override
	public Dictionary selectById(Integer id) {
		// TODO Auto-generated method stub
		String hql = "from Dictionary where dic_id=?";
		Dictionary dictionary = dictionaryDao.selectById(hql, id);
		return dictionary;
	}

	@Override
	public void update(Dictionary dictionary) {
		// TODO Auto-generated method stub
		dictionaryDao.update(dictionary);
	}

	@Override
	public List<Dictionary> selectAll() {
		// TODO Auto-generated method stub
		String hql = "from Dictionary";
		List<Dictionary> dictionaryList = dictionaryDao.selectAll(hql);
		return dictionaryList;
	}

	@Override
	public List<Dictionary> getPage(Page page) {
		// TODO 自动生成的方法存根
		String hql = "from Dictionary";
		return dictionaryDao.getPage(hql, page);
	}

	@Override
	public int getCount() {
		// TODO 自动生成的方法存根
		String hql = "select count(*) from Dictionary";
		return dictionaryDao.getCount(hql);
	}

	@Override
	public int getCount(String searchname) {
		// TODO 自动生成的方法存根
		return dictionaryDao.search(searchname, null).size();
	}

	@Override
	public List<Dictionary> search(String searchname, Page page) {
		// TODO 自动生成的方法存根
		return dictionaryDao.search(searchname, page);
	}
}
